package com.commpany.servie.basic.product.service.write;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import lombok.extern.slf4j.Slf4j;
import com.commpany.jiedianqian.system.exception.BusinessException;
import com.commpany.jiedianqian.system.exception.SystemErrorEnum;
import com.commpany.servie.basic.product.api.write.ProductWriteService;
import com.commpany.servie.basic.product.converter.ProductConverter;
import com.commpany.servie.basic.product.business.write.product.ProductWriteManage;
import com.commpany.servie.basic.product.model.dto.product.ProductDTO;
@Slf4j
@Service("productWriteService")
public class ProductWriteServiceImpl  implements ProductWriteService {
	@Autowired
	private ProductWriteManage productWriteManage;
	
	public int insertProductService( ProductDTO inputDTO ){
	   try {
	       return productWriteManage.insertProductService(ProductConverter.toPO(inputDTO));
	     } catch (Exception e) {
			// TODO Auto-generated catch block
			log.error("系统异常", e);
			throw new BusinessException(SystemErrorEnum.SYSTEM_ERROR.getValue(), SystemErrorEnum.SYSTEM_ERROR.name());
		}
	}
    public int updateProductService( ProductDTO inputDTO ){
       try {
           return productWriteManage.updateProductService(ProductConverter.toPO(inputDTO));
        } catch (Exception e) {
			// TODO Auto-generated catch block
			log.error("系统异常", e);
			throw new BusinessException(SystemErrorEnum.SYSTEM_ERROR.getValue(), SystemErrorEnum.SYSTEM_ERROR.name());
		}
    }
    public int deleteProductService( ProductDTO inputDTO ){
      try {
          return productWriteManage.deleteProductService(ProductConverter.toPO(inputDTO));
      } catch (Exception e) {
			// TODO Auto-generated catch block
			log.error("系统异常", e);
			throw new BusinessException(SystemErrorEnum.SYSTEM_ERROR.getValue(), SystemErrorEnum.SYSTEM_ERROR.name());
		}
    }
}
	